package com.code.family.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 账户类型枚举类
 * @author 上玄
 */

@Getter
public enum AccountType {
    BANK(1, "银行"),
    CREDIT_CARD(2, "信用卡"),
    WECHAT(3, "微信"),
    ALIPAY(4, "支付宝");

    @EnumValue
    private final int value;
    @JsonValue
    private final String desc;

    AccountType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static AccountType fromValue(int value) {
        for (AccountType type : AccountType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown value: " + value);
    }
}
